﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Common;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Input;

namespace XnaSuperGame
{
	class StartMenu 
	{
		#region ClassMemebers

		GameButton StartGame;
		GameButton StartRedactor;

		ContentHelper ContentHelper;
		private GameStates TargetState = GameStates.Menu;

		Dictionary<int, GameButton> MenuBtnList = new Dictionary<int, GameButton>();
		
		private float _intend;
		private Vector2  _fixedPosition;
		
		public float Intend
		{
			get {return _intend;}
			set {_intend = value;}
		}
		public Vector2 FixedPositoin
		{
			get {return _fixedPosition;}
			set {_fixedPosition = value;}
		}
		
		#endregion

		public StartMenu(Game game) 
		{
			ContentHelper = new ContentHelper(game.Content);

			StartGame = new GameButton(game.Window, 
												ContentHelper.GetTexture("start-icon", ContentTypes.Sprite),
												GameStates.Game);

			StartRedactor = new GameButton(game.Window,
													ContentHelper.GetTexture("Nurf", ContentTypes.Sprite),
													GameStates.Redactor);

			MenuBtnList.Add(1,StartGame);
			MenuBtnList.Add(2,StartRedactor);
									
		}

		public void Update(MouseState mouseState) 
		{

			foreach (KeyValuePair<int, GameButton> kvp in MenuBtnList.OrderBy(x => x.Key))
			{
				var menuBtn = kvp.Value;
				menuBtn.Update(mouseState);
				if(menuBtn.IsClicked)
				{
					TargetState = menuBtn.TargetState();
				}
			}

		}

		public void Draw(SpriteBatch spriteBatch)
		{
			foreach (KeyValuePair<int, GameButton> kvp in MenuBtnList.OrderBy(x => x.Key))
			{
				kvp.Value.Draw(spriteBatch);
					
			}
		}

		public GameStates GetState() { return TargetState; }
				
	}



}
